import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;


public class Client {
	
	public static void main(String argv[]) throws UnknownHostException, IOException
	{
		//host port mode name
		if(argv.length!=4)
		{
			System.out.println("Usage: host port mode name");
			System.exit(1);
		}
		
		String host = argv[0];
		int port = Integer.parseInt(argv[1]);
		int mode = Integer.parseInt(argv[2]);
		String name = argv[3];
		Socket clientSocket = new Socket("localhost",8888);
		BufferedReader reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
		PrintWriter writer = new PrintWriter(clientSocket.getOutputStream(),true);
		writer.println(name);
		
		String content = null;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		while( !(content = reader.readLine()).contains("END")){
			String output = in.readLine();
			writer.println(output);
		}
		
		
	}
	
}
